import { defineStore } from 'pinia'

export const useDashboardStore = defineStore('dashboard', {
  state: () => ({
    stats: {
      visits: 0,
      sales: 0,
    },
  }),
  actions: {
    async fetchStats() {
      // 从 API 获取数据并更新 state
    //   const data = await api.getDashboardStats()
    //   this.stats = data
    },
    async getStats() {
      // 模拟获取统计数据
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve({
            visits: Math.floor(Math.random() * 1000),
            sales: Math.floor(Math.random() * 500),
          })
        }, 1000)
      })
    },
    async getCharts() { 
    },
    async getActivities() {
      // 模拟获取活动数据
      return new Promise((resolve) => {
        setTimeout(() => {
          resolve([
            { id: 1, title: '用户注册', date: '2023-10-01' },
            { id: 2, title: '订单创建', date: '2023-10-02' },
            { id: 3, title: '产品上架', date: '2023-10-03' },
          ])
        }, 1000)
      })
    }
  },
})